if SERVER then
	registerCommand("god", "Turn on/off god mode on the specified player", function(param)
		local godOn = "caller gave target god"
		local godOff = "caller took god from target"
		if param["settings"]["god_msg_on"] then
			godOn = param["settings"]["god_msg_on"]
		end
		if param["settings"]["god_msg_off"] then
			godOff = param["settings"]["god_msg_off"]
		end
		local godTable = {}
		godTable["caller"] = getCaller(param[1])
		local targs = string.Explode(" ", param[3])
		if targs[1] == "all" then
			targs = player.GetAll()
		end
		local plyTarg = 0
		for i, targ in pairs(targs) do
			if (not targ) || targ == "" then
				if not param[1]:IsValid() then
					return nil
				end
				plyTarg = param[1]
			else
				plyTarg = getPlayerByName(targ)
			end
			if plyTarg then
				godTable["target"] = plyTarg:GetName()
				if (not plyTarg["moocow_god"]) || plyTarg["moocow_god"] == -1 then
					display(param[1], "god", { plyTarg }, parseDisplayMessage(godOn, godTable))
					plyTarg["moocow_god"] = 1
				else
					display(param[1], "god", { plyTarg }, parseDisplayMessage(godOff, godTable))
					plyTarg["moocow_god"] = -1
				end
			end
		end
	end)
	
	local function gotplyTookDmg(ply, attacker)
		if ply["moocow_god"] == 1 then
			return false
		end
	end
	hook.Add("PlayerShouldTakeDamage", "moocow_goddamage", gotplyTookDmg)
	
	/*local function godplyTookDmg(ply, attacker, remaining, dmg)
		if ply["moocow_god"] == 1 then
			ply:SetHealth(ply:Health() + dmg)
		end
	end
	hook.Add("PlayerHurt", "moocow_god", godplyTookDmg)*/
end